package com.moleq.test;

import android.content.Context;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class MyGestureListener extends SimpleOnGestureListener implements OnTouchListener 
{ 
    private Context context; 
    private GestureDetector gDetector;
//	private FlipChartPanelTest mFlipChartGridView; 

    public MyGestureListener() 
    { 
        super(); 
    } 

    public MyGestureListener(Context context) { 
        this(context, null); 
    } 

    public MyGestureListener(Context context, GestureDetector gDetector) { 

        if(gDetector == null) 
            gDetector = new GestureDetector(context, this); 

        this.context = context; 
        this.gDetector = gDetector; 
    } 
    
           
//	public MyGestureListener(Context con, GestureDetector gDetector, FlipChartPanelTest fcGridView){  
//		this(con, gDetector); 
//	    this.mFlipChartGridView = fcGridView;  
//	}  



    @Override 
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { 
    	
    	
    	
		if (e1.getX() - e2.getX() > 50) {
			// m_vfDishList.showNext();
//			mFlipChartGridView.showNext();
//			Toast.makeText(context,
//					"onFling left ", Toast.LENGTH_LONG)
//					.show();
			return true;
		} else if (e2.getX() - e1.getX() > 50) {
			// m_vfDishList.showPrevious();
//			mFlipChartGridView.showPrevious();
//			Toast.makeText(context,
//					"onFling right ", Toast.LENGTH_LONG).show();
			return true;
		}
		return true;
    	 
       // return super.onFling(e1, e2, velocityX, velocityY); 
    } 

    @Override 
    public boolean onSingleTapConfirmed(MotionEvent e) { 

        return super.onSingleTapConfirmed(e); 
    } 





    public boolean onTouch(View v, MotionEvent event) { 

        // Within the MyGestureListener class you can now manage the event.getAction() codes. 

        // Note that we are now calling the gesture Detectors onTouchEvent. And given we've set this class as the GestureDetectors listener  
        // the onFling, onSingleTap etc methods will be executed. 
        return gDetector.onTouchEvent(event); 
    } 


    public GestureDetector getDetector() 
    { 
        return gDetector; 
    }        
} 
